package com.dou.sample.opengl_project.shader;

import android.content.Context;

import com.dou.sample.opengl_project.utls.ShaderHelper;
import com.dou.sample.opengl_project.utls.TextResourceReader;

import static android.opengl.GLES20.glUseProgram;

/**
 * Created by Dou on 2018/1/16.
 */

public class ShaderProgram {
    public static final String A_POSITION = "a_Position";
    public static final String A_TEXTURECOODINATES = "a_TextureCoodinates";
    public static final String A_COLOR = "a_Color";
    public static final String U_MATRIX = "u_Matrix";
    public static final String U_TEXTUREUNIT = "u_TextureUnit";
    public static final String U_COLOR = "u_Color";


    int program;

    public ShaderProgram(Context context, int vertexResourceId, int fragmentResourceId){
        program = ShaderHelper.buildProgram(TextResourceReader.readTextFileFromResource(context, vertexResourceId),
                TextResourceReader.readTextFileFromResource(context, fragmentResourceId));
    }

    public void useProgram(){
        glUseProgram(program);
    }
}
